package com.wc.alorithm_luogu.P1085;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/18 10:52
 * @description https://www.luogu.com.cn/problem/P1085
 * 不高兴的津津
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = 0;
        int max = 0;
        int curMaxDay = 1;
        // 上课时间
        int classTime;
        // 额外时间
        int extraTime;
        while (++x < 8) {
            classTime = sc.nextInt();
            extraTime = sc.nextInt();
            if (classTime + extraTime > max) {
                max = classTime + extraTime;
                curMaxDay = x;
            }
        }
        /**
         * 超过8小时才不高兴
         */
        if (max <= 8) {
            System.out.println(0);
        } else {
            System.out.println(curMaxDay);
        }
    }
}
